<?php
use yii\helpers\Html;
use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;
LayerConfirmWidget::widget();
LayerIframeWidget::widget();
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2 zx-min-height">
    <?= $this->renderFile('@app/modules/cus/views/layouts/toolbar.php'); ?>
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
        <div style="width:100%;height:40px;">
        <?= Html::beginForm(Fun::url(['cus/customer/index']), 'get',['id'=>'myform']) ?>
        <?= \common\components\helpers\Search::textInput('tel', \Yii::$app->request->get('tel'), ['label'=>'会员手机号','labelclass'=>'yx-label','class' => 'search yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::textInput('name', \Yii::$app->request->get('name'), ['label'=>'会员名称','labelclass'=>'yx-label','class' => 'search  yx-width150 zx-lh24 yx-ml6']); ?>
        <?=\common\components\helpers\Search::dropDownList('customer_status',\Yii::$app->request->get('customer_status'),$list,['label'=>'会员等级','labelclass'=>'yx-label','promote'=>'请选择','class'=>'search diy_select_txt'])?>
        <?=Html::hiddenInput('sort',\Yii::$app->request->get('sort'))?>
        <?= Html::submitButton('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
        </div>
        <?php Html::endForm() ?>
    </div>
    <div class="docs-main zx-mg">
        <?=\yii\grid\GridView::widget([
            'dataProvider'=>$dataProvider,
            'tableOptions' =>['class'=>'tablesaw table yx-table1 yx-table3 table-striped with-check','data-tablesaw-mode'=>"swipe",'data-tablesaw-minimap'=>''],
            'columns'  =>[
                [
                    'attribute'=>'name',
                    'label'=>'姓名'
                ],
                [
                    'attribute'=>'sex',
                    'value'=>function($model){
                         return $model->sex == 'Female'?'女':'男';
                    },
                    'label'=>'性别'
                ],
                [
                    'attribute'=>'age',
                    'value'=>function($model){
                        return ($model->age > 0)?(int)date('Y')-$model->age:'未设置';
                    },
                    'label'=>'年龄'
                ],
                [
                    'attribute'=>'mobile',
                    'label'=>'手机号码'
                ],
                [
                    'attribute'=>'email',
                    'label'=>'邮箱'
                ],
                [
                    'attribute'=>'grade_id',
                    'value' =>'grade.name',
                    'label'=>'等级'
                ],
                [
                    'attribute'=>'created_at',
                    'value' =>function($model){
                          return \Yii::$app->formatter->asDatetime($model->created_at);
                    },
                    'label'=>'加入时间'
                ],
                [
                    "class" => "yii\grid\ActionColumn",
                    "template" => "{details}{update}{account}",
                    "header" => "操作",
                    "buttons" => [
                        "details" => function ($url, $model) {
                            return (new MenuManage(Menumanage::RECORD_ITEM_TOOLBAR))->detailsMenu('customer', 'details', true, [ 'class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2 yx-mr5', 'data' => ['id' => $model->id]],'cus');
                        },
                        'account' => function($url,$model) {
                            return (new MenuManage(Menumanage::RECORD_ITEM_TOOLBAR))->detailsMenu('customer', 'account', true, ['class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2', 'data' => ['id' => $model->id]], 'cus');
                        },
                        'update' => function($uel,$model){
                            return (new MenuManage(Menumanage::RECORD_ITEM_TOOLBAR))->detailsMenu('customer', 'update', true, [ 'class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2 yx-mr5', 'data' => ['id' => $model->id]],'cus');
                        }
                    ],
                ],
            ],
            'emptyText'=>'当前没有数据',
            'emptyTextOptions'=>['style'=>'color:red;font-weight:bold'],
            'layout' => "{items}\n<div style='text-align: right'>{pager}</div>",
            'showOnEmpty'=>false,
            'captionOptions' => ['style' => 'border:1px solid rgb(238, 238, 238);padding: 10px 0px;'],
            'headerRowOptions' => ['class' => 'yx-bgd2f6ec'],
            'footerRowOptions' => ['class' => 'yx-floatl yx-color73bbef yx-font13 yx-lh24'],
            'pager' => [
                'class' => \common\components\widgets\GoPager::className(),
            ]
        ]);?>

    </div>


